package com.ybkj.chat.module.mine.activity;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.ybkj.chat.R;
import com.ybkj.chat.base.BaseMvpActivity;
import com.ybkj.chat.ui.adapter.ViewPagerAdapter;
import com.ybkj.chat.ui.dialog.ChoosePayDialog;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * @author yyj
 * @create 2019-02-25 16:03
 * @Describe
 */
public class VipCenterActivity extends BaseMvpActivity {
    @BindView(R.id.vp_pager_vip)
    ViewPager vpPagerVip;

    private List<View> viewList = new ArrayList<>();
    private int[] imgResources = {R.layout.pager_normal_vip, R.layout.pager_normal_vip};

    @Override
    protected void injectPresenter() {

    }

    @Override
    protected void initTitle() {

    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_vip_center;
    }

    @Override
    protected void initView() {
        for (int i = 0; i < imgResources.length; i++) {
            View view = LayoutInflater.from(this).inflate(imgResources[i], null);
            viewList.add(view);
        }
        //设置page间距
        vpPagerVip.setPageMargin(40);
        vpPagerVip.setOffscreenPageLimit(3);
        vpPagerVip.setAdapter(new PagerAdapter() {
            @Override
            public int getCount() {
                return viewList.size();
            }

            @Override
            public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
                return view == object;
            }

            @NonNull
            @Override
            public Object instantiateItem(@NonNull ViewGroup container, int position) {
                View view = viewList.get(position);
                container.addView(view);
                switch (position){
                    case 0:
                        TextView tv_open = view.findViewById(R.id.tv_open);
                        tv_open.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View view) {
                                ChoosePayDialog choosePayDialog = new ChoosePayDialog(VipCenterActivity.this);
                                choosePayDialog.setCanceledOnTouchOutside(false);
                                choosePayDialog.show();
                            }
                        });
                        break;
                    case 1:
                        TextView tv_open1 = view.findViewById(R.id.tv_open);
                        tv_open1.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View view) {
                                ChoosePayDialog choosePayDialog = new ChoosePayDialog(VipCenterActivity.this);
                                choosePayDialog.setCanceledOnTouchOutside(false);
                                choosePayDialog.show();
                            }
                        });
                        break;
                }
                return view;
            }
        });
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

//    @Override
//    public boolean isImmersiveStatusBar() {
//        return true;
//    }
//
//    @Override
//    protected int immersiveStatusBarColor() {
//        return R.color.transparent;
//    }
}
